﻿using FangPage.Common;
using FangPage.Core;
using FangPage.Data;
using FangPage.User;
using FangPage.User.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace FangPage.User.Controller
{
    public class role_add: UserController
    {
        protected RoleInfo roleinfo = new RoleInfo();

        public override void Controller()
        {
            string id = FPRequest.GetString("id");

            if (!id.IsNullOrEmpty())
            {
                roleinfo = DbHelper.ExcuteModel<RoleInfo>(id);
            }

            if (ispost)
            {
                roleinfo = FPRequest.GetModel(roleinfo);

                if (roleinfo.id.IsNullOrEmpty())
                {
                    DbHelper.ExcuteInsert(roleinfo);

                    FPResponse.WriteSuccess("添加成功");
                }
                else
                {
                    DbHelper.ExcuteUpdate(roleinfo);

                    FPResponse.WriteSuccess("修改成功");
                }
            }

            FPResponse.WriteData(roleinfo);
        }
    }
}
